<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of filer
 *
 * @author Admin
 */
class File
{
    protected $_prefix = '';


    public function __construct( $prefix )
    {
	$this->_prefix = $prefix;
    }
    
    public function save( $file, $data )
    {
	$data = json_encode( $data );
	return $this->_save( $file, $data );
    }
    
    public function get( $file )
    {
	return json_decode( $this->_get( $file ) );
    }
    
    public function fileExists( $file )
    {
	return file_exists( data_path . $file . '.' . $this->_prefix . '.dat' );
    }
    
    protected function _save( $file, $data )
    {
	return file_put_contents( data_path . $file . '.' . $this->_prefix . '.dat', $data );
    }
    
    protected function _get( $file )
    {
	return file_get_contents( data_path . $file . '.' . $this->_prefix . '.dat' );
    }
    
}

?>
